<script>
    $(document).ready(function(){
        $( "#tabs" ).tabs();
        $('#lista').dataTable( {
            "sPaginationType": "full_numbers",
            "iDisplayLength":100
        });
        $('#lista1').dataTable( {
            "sPaginationType": "full_numbers",
            "iDisplayLength":25
        })
    });
</script>
<?php echo $this->Html->link('Impresión carta de subsanación', array('controller' => 'Proyects', 'action' => 'subsanaciones'), array('class' => 'actions', 'target' => 'blank_')); ?>
<br><br>
<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Filtro Proyecto</a></li>
        <li><a href="#tabs-2">Filtro Familias</a></li>
        <li><a href="#tabs-3">Filtro Predios</a></li>
        <li><a href="#tabs-4">Estudio de Titulos</a></li> 
        <li><a href="#tabs-5">Carta Habilitado o Rechazado</a></li>

    </ul>
    <div id="tabs-1">
        <table border="0" cellpadding="2px" cellspacing="3px" width="100%"  >

            <thead>

            <th>Concepto</th>
            <th>Calificación</th>

            </thead>
            <tbody>

                <?php
                if (empty($req_proyecto)) {
                    echo "<h1>NO SE HA REALIZADO FILTRO SOBRE ESTE PROYECTO</h1>";
                } else {

                    foreach ($req_proyecto as $req):

                        switch ($req['ProyectRequirement']['calificacion']) {
                            case 0:
                                $cal = "Sin Registro";
                                break;
                            case 1:
                                $cal = "Cumple";
                                break;
                            case 2:
                                $cal = "No Cumple";
                                break;
                            case 3:
                                $cal = "Subsanable";
                                break;


                            default:
                                $cal = "";
                                break;
                        }
                        ?>

                        <tr style="background:white; color: maroon"><td> <?php echo $req['Requirement']['texto'] ?></td><td><?php echo $cal ?> </td></tr>


                        <?php
                        foreach ($req['RequirementFault']as $fault):
                            switch ($fault['tipo']) {

                                case 0:
                                    $cal1 = "Sin Registro";
                                    break;
                                case 1:
                                    $cal1 = "Cumple";
                                    break;
                                case 2:
                                    $cal1 = "No Cumple";
                                    break;
                                case 3:
                                    $cal1 = "Subsanable";
                                    break;


                                default:
                                    $cal1 = "";
                                    break;
                            }
                            ?>
                            <tr style="background:aqua;"><td> <?php echo $fault['nombre'] ?></td><td><?php echo $cal1 ?> </td></tr>
                            <?php
                        endforeach;
                        ?>

                        <?php
                    endforeach;
                }
                ?>
            </tbody>
        </table>

    </div>
    <div id="tabs-2">

        <table border="0" cellpadding="2px" cellspacing="3px" width="100%" id="lista">

            <thead>
                <tr>
                    <th width="10%">Nombre</th>
                    <th width="60%">Concepto</th>
                    <th width="30%">Calificación</th>
                </tr>

            </thead>
            <tbody>

                <?php $cont = 1; ?>

                <?php foreach ($aspirantes as $asp): ?>
                    <?php
                    $name = $asp['Candidate']['1er_nombre'] . " " . $asp['Candidate']['2do_nombre'] . " " . $asp['Candidate']['1er_apellido'] . " " . $asp['Candidate']['2do_apellido'];
                    $rqc = $asp['Requirement']['texto'];
                    switch ($asp['CandidateRequirement']['calificacion']) {

                        case 0:
                            $calcan = "Sin Registro";
                            break;
                        case 1:
                            $calcan = "Cumple";
                            break;
                        case 2:
                            $calcan = "No Cumple";
                            break;
                        case 3:
                            $calcan = "Subsanable";
                            break;


                        default:
                            $calcan = "";
                            break;
                    }
                    ?>
                    <tr style="background:white; color: maroon"><td width="5%"><?php echo $name ?></td><td width="80%"> <?php echo $rqc ?></td><td width="15%"> <?php echo $calcan ?></td></tr>

                    <?php
                    foreach ($asp['RequirementFault'] as $reqfault) {
                        $rfc = $reqfault['nombre'];
                        switch ($reqfault['tipo']) {

                            case 0:
                                $ca = "Sin Registro";
                                break;
                            case 1:
                                $ca = "Cumple";
                                break;
                            case 2:
                                $ca = "No Cumple";
                                break;
                            case 3:
                                $ca = "Subsanable";
                                break;


                            default:
                                $ca = "";
                                break;
                        }

                        echo " <tr style='background:#becdcd; color: red'><td>$name</td><td>$rfc</td><td>$ca</td></tr>";
                    }
                    ?>


                <?php endforeach ?>

                <?php
                foreach ($aspirantes_totales as $asp_t) {
                    $indicador = false;

                    foreach ($aspirantes as $asp) {

                        if ($asp_t['Candidate']['id'] == $asp['Candidate']['id']) {
                            $indicador = true;
                        }
                    }
                    $name = $asp_t['Candidate']['1er_nombre'] . " " . $asp_t['Candidate']['2do_nombre'] . " " . $asp_t['Candidate']['1er_apellido'] . " " . $asp_t['Candidate']['2do_apellido'];

                    if ($indicador == false) {
                        echo " <tr style='background:red; color:white'><td>" . $name . "</td><td colspan='2'>NO SE HA REALIZADO FILTRO SOBRE ESTE ASPIRANTE</td></tr>";
                    }
                }
                ?>

            </tbody>
        </table>



    </div>
    <div id="tabs-3">
        <table>
            <?php foreach ($predios as $predio): ?>
                <?php
                $nomb = $predio['Property']['nombre'];
                $rq = $predio['Requirement']['texto'];

                switch ($predio['PropertyRequirement']['calificacion']) {

                    case 0:
                        $cal = "Sin Registro";
                        break;
                    case 1:
                        $cal = "Cumple";
                        break;
                    case 2:
                        $cal = "No Cumple";
                        break;
                    case 3:
                        $cal = "Subsanable";
                        break;


                    default:
                        $cal = "";
                        break;
                }


                echo " <tr style='background:white; color: maroon'><td>$nomb</td><td>$rq</td><td>$cal</td></tr>";
                foreach ($predio['RequirementFault'] as $reqfault) {
                    $rfl = $reqfault['nombre'];
                    switch ($reqfault['tipo']) {

                        case 0:
                            $ca = "Sin Registro";
                            break;
                        case 1:
                            $ca = "Cumple";
                            break;
                        case 2:
                            $ca = "No Cumple";
                            break;
                        case 3:
                            $ca = "Subsanable";
                            break;

                        default:
                            $ca = "";
                            break;
                    }

                    echo " <tr style='background:#becdcd; color: red'><td>$nomb</td><td>$rfl</td><td>$ca</td></tr>";
                }
                ?>

            <?php endforeach ?>

            <?php
            foreach ($predios_totales as $pred_t) {
                $indicador = false;

                foreach ($predios as $pre) {

                    if ($pred_t['Property']['id'] == $pre['Property']['id']) {
                        $indicador = true;
                    }
                }
                $name = $pred_t['Property']['codigo'];
                if ($indicador == false) {
                    echo " <tr style='background:red; color:white'><td>" . $name . "</td><td colspan='2'>NO SE HA REALIZADO FILTRO SOBRE ESTE PREDIO</td></tr>";
                }
            }
            ?>

        </table>

    </div>
    <div id="tabs-4">


        <table cellpadding="2px" cellspacing="3px" width="100%" id="lista1" >

            <thead>
                <tr>
                    <th width="10%">Codigo</th>
                    <th width="60%">Nombre</th>
                    <th width="30%">Concepto</th>
                    <th width="30%">Calificación</th>
                </tr>

            </thead>
            <tbody>
                <?php foreach ($titulos as $titulo): ?>
                    <?php
                    $nomb = $titulo['Property']['nombre'];
                    $cod = $titulo['Property']['codigo'];
                    $vh = $titulo['TitleStudy']['valor_hipoteca'];
                    $con = $titulo['TitleStudy']['concepto'];
                    $req = $titulo['TitleStudy']['recomendaciones'];
                    $doc = $titulo['TitleStudy']['doc_subsanacion'];
                    $obs = $titulo['TitleStudy']['area_obs'];


                    switch ($titulo['TitleStudy']['calificacion']) {

                        case 0:
                            $cal = "Sin Registro";
                            break;
                        case 1:
                            $cal = "Cumple";
                            break;
                        case 2:
                            $cal = "No Cumple";
                            break;
                        case 3:
                            $cal = "Subsanable";
                            break;


                        default:
                            $cal = "";
                            break;
                    }

                    echo " <tr style='background:white; color: maroon'><td>$cod</td><td>$nomb</td><td>$con</td><td>$cal</td></tr>";
                    ?>

                <?php endforeach; ?>
                <?php
                foreach ($predios_totales as $pred_t) {
                    $indicador = false;

                    foreach ($titulos as $pre) {

                        if ($pred_t['Property']['id'] == $pre['Property']['id']) {
                            $indicador = true;
                        }
                    }
                    $name = $pred_t['Property']['codigo'];
                    if ($indicador == false) {
                        echo " <tr style='background:red; color:white'><td>" . $name . "</td><td colspan='2'>NO SE HA REALIZADO ESTUDIO DE TITULOS SOBRE ESTE PREDIO</td></tr>";
                    }
                }
                ?>
            </tbody>
        </table>

    </div>
    <div id="tabs-5">

        <?php echo $html->link('Generar Carta de Resultado', array('controller' => 'proyects', 'action' => 'result_letter'), array('class' => 'actions', 'target' => '_blank')) ?>

    </div>



</div> 
